<?php

namespace LowCode\Support;


use LowCode\Traits\HasMake;

/**
 * @method static $this make(string $ref)
 */
class JsDs extends Fluent
{
    use HasMake;

    /**
     * @param string $ref JsApi里的id值
     */
    public function __construct(string $ref)
    {
        parent::__construct([
            "type"=>"api",
        ]);
        $this->ref($ref);
    }

    /**
     * @param string $ref
     * @return $this
     */
    public function ref(string $ref): static
    {
        return $this->setAttribute("ref",$ref);
    }

    /**
     * @param string $name
     * @return $this
     */
    public function name(string $name): static
    {
        return $this->setAttribute("name",$name);
    }

    public function api()
    {

    }

    /**
     * 数据转换函数
     * @param JsFn $transform
     * @return $this
     */
    public function transform(JsFn $transform): static
    {
        return $this->setAttribute("transform", $transform);
    }

    /**
     * 描述标题
     * @param string $label
     * @return $this
     */
    public function label(string $label): static
    {
        return $this->setAttribute("label", $label);
    }
}
